package cn.doit.scala.day01.method

/**
 * @DATE 2021/12/24/16:54
 * @Author MDK
 * @Version 2021.2.2
 * */
object C03_Test03 {
  def optArray[T](arr:Array[T], f:Array[T]=>Array[T])={
    f(arr)
  }
  def main(args: Array[String]): Unit = {
    val res1: Array[Int] = optArray[Int](Array[Int](1,3,2,4,5,8,7),
      arr=>{
        val newArray : Array[Int] = for (elem <- arr) yield elem * 10
        newArray
      }
    )

    val res2: Array[Int] =optArray[Int](Array[Int](1,3,5,2,6),
      arr=>{
        val array: Array[Int] = for (elem <- arr) yield elem*elem
        array
      })

    val res: Array[String] = optArray[String](Array[String]("hbase","java","scala","sql"),
      arr=>{
        val array = for (elem <- arr) yield elem.toUpperCase()
        array
      })

    println(res.toList)
  }

}
